var watch = require('watch')



// var watchCallBack = (f, curr, prev) => {
//     if (typeof f == "object" && prev === null && curr === null) {
//         console.log("Finished walking the tree")
//     } else if (prev === null) {
//         console.log(f + " created")
//         watch.watchTree(f, watchCallBack)
//     } else if (curr.nlink === 0) {
//         console.log(f + " removed")
//         watch.unwatchTree(f);
//     } else {
//         console.log(f + " changed")
//         // f was changed
//     }
// }

// watch.watchTree('./floor', watchCallBack)
watch.createMonitor('./floor', function (monitor) {
    // monitor.files['./test/watch/floor/t2.js'] // Stat object for my zshrc.
    monitor.on("created", function (f, stat) {
        // Handle new files
        console.log('create  ' + f );
    })
    monitor.on("changed", function (f, curr, prev) {
        // Handle file changes
        console.log('changed  ' + f );
    })
    monitor.on("removed", function (f, stat) {
        // Handle removed files
        console.log('removed  ' + f);
    })
   //  monitor.stop(); // Stop watching
})

